package com.zlzxm.sorting.util.ui.manager

import android.os.Bundle
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat


/**
 *
 *CREATE BY zlzxm ON 2022/7/5
 *
 */
abstract class AbsAcBase : AcBase(), IPageManager {



    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initBinding()?.let {
            setContentView(it.root)

        }
        initViewModel()
        initView()
        initData()

    }

    //是否将布局延展致状态栏
     fun setDecorFitsSystemWindows(isFit:Boolean){

         WindowCompat.setDecorFitsSystemWindows(window, isFit)
     }

    fun hideNavigationBars(){

       val  insets  = WindowCompat.getInsetsController(window,window.decorView)

        insets?.hide(WindowInsetsCompat.Type.navigationBars())
    }

    fun hideStatusBars(){

        val  insets  = WindowCompat.getInsetsController(window,window.decorView)

        insets?.hide(WindowInsetsCompat.Type.statusBars())
    }


    fun fullScreenMode(){
        setDecorFitsSystemWindows(false)
        val  insets  = WindowCompat.getInsetsController(window,window.decorView)
        insets?.hide(WindowInsetsCompat.Type.systemBars())
        insets?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
    }

    fun setStatusBarTextColor(isLight:Boolean){
        val insetsController = WindowCompat.getInsetsController(window, window.decorView)
        insetsController?.isAppearanceLightStatusBars = isLight  //true：黑色 ，false：白色

    }


}